<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Rental filter form base class.
 *
 * @package    juvenalis
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormFilterGeneratedTemplate.php 16976 2009-04-04 12:47:44Z fabien $
 */
class BaseRentalFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'prefix'      => new sfWidgetFormFilterInput(),
      'suffix'      => new sfWidgetFormFilterInput(),
      'title'       => new sfWidgetFormFilterInput(),
      'description' => new sfWidgetFormFilterInput(),
      'rating'      => new sfWidgetFormFilterInput(),
      'broken'      => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'deleted'     => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'turnover'    => new sfWidgetFormFilterInput(),
      'rents'       => new sfWidgetFormFilterInput(),
      'note'        => new sfWidgetFormFilterInput(),
      'place'       => new sfWidgetFormFilterInput(),
      'price_id'    => new sfWidgetFormPropelChoice(array('model' => 'Price', 'add_empty' => true)),
      'carrier_id'  => new sfWidgetFormPropelChoice(array('model' => 'Carrier', 'add_empty' => true)),
      'created_at'  => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at'  => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
    ));

    $this->setValidators(array(
      'prefix'      => new sfValidatorPass(array('required' => false)),
      'suffix'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'title'       => new sfValidatorPass(array('required' => false)),
      'description' => new sfValidatorPass(array('required' => false)),
      'rating'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'broken'      => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'deleted'     => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'turnover'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'rents'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'note'        => new sfValidatorPass(array('required' => false)),
      'place'       => new sfValidatorPass(array('required' => false)),
      'price_id'    => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Price', 'column' => 'id')),
      'carrier_id'  => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Carrier', 'column' => 'id')),
      'created_at'  => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'  => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('rental_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Rental';
  }

  public function getFields()
  {
    return array(
      'id'          => 'Number',
      'prefix'      => 'Text',
      'suffix'      => 'Number',
      'title'       => 'Text',
      'description' => 'Text',
      'rating'      => 'Number',
      'broken'      => 'Boolean',
      'deleted'     => 'Boolean',
      'turnover'    => 'Number',
      'rents'       => 'Number',
      'note'        => 'Text',
      'place'       => 'Text',
      'price_id'    => 'ForeignKey',
      'carrier_id'  => 'ForeignKey',
      'created_at'  => 'Date',
      'updated_at'  => 'Date',
    );
  }
}
